<template>
  <!-- 人员信息维护-->
  <div>
    <!-- 搜索 -->
    <TopFilter  
      :list="topFilterInit"  
      :cols="3"  
      labelWidth="100"  
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
      ></TopFilter>
     <!-- table -->
    <FilterTable   ref="table" :columns="columns"   
       :fetchapi="fetchParams" 
       :isSelectColumn="isSelectColumn"
       :params="flterValue" :datakey="'records'"
       :onColumnsChange="columns => this.columns = columns">
      <template slot="controls" >
       <el-button size="small" type="primary" icon="el-icon-plus" @click="dialogHandle(null,'show')">新增</el-button>
      </template>
   </FilterTable>
    <!-- 经销商弹窗 -->
   <BaseDialog title="人员信息维护" :visible.sync="visible"
      width="800px"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}" >
      <addDialog v-model="initData" @close="dialogClose" />
   </BaseDialog>
  </div>
</template>
<script>
import addDialog from './addDialog'
import { dictionary } from '@/utils/dictMixin';
export default {
  components: {
    addDialog
  },
  mixins: [dictionary],
  data() {
    return {
      visible:false,
      isSelectColumn:false,
      initData:{},
      topFilterInit:this.topFilterInitFun(),
      flterValue:{},  //参数
      columns:this.creatHeader(),
      fetchParams:null, //ipa 接口
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods: {
      //搜索数据
      topFilterInitFun(){
        return [
            { type: 'INPUT',   label: '部门名称',    fieldName: 'field1',  placeholder: '请输入',  initialValue: ''},
            { type: 'INPUT',   label: '员工姓名',    fieldName: 'field3',  placeholder: '请输入',  initialValue: ''},
            { type: 'INPUT',   label: '员工编号',    fieldName: 'field7',  placeholder: '请输入',  initialValue: ''},
            { type: 'SELECT',  label: '在职状态',  fieldName: 'field2',  placeholder: '请选择', initialValue: "", itemList:  this.createDictList('1008') },
            { type: 'SELECT',  label: '岗位名称', fieldName: 'field5',  placeholder: '请选择', initialValue: "", itemList:  this.createDictList('1008') }
        ]
      },
      //搜索获取数据
      changeHandle(val){
          this.flterValue=val
          console.log(val)
      },
      //table表头和数据源
      creatHeader(){
         return [
         {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
         },
         {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.dialogHandle(props.row,'edit')}>
                  编辑
                </el-button>
                <el-divider direction="vertical" />
                <el-button size="mini" type="text" onClick={() => this.dialogHandle(props.row,'show')}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        { title: '员工编号',  dataIndex: 'field0', sorter: true},
        { title: '员工姓名',  dataIndex: 'field1', sorter: true},
        { title: '性别',  dataIndex: 'field2', sorter: true,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }},
        { title: '身份证号码',   dataIndex: 'field3', sorter: true},
        { title: '部门名称',    dataIndex: 'field4',  sorter: true},
        { title: '岗位名称',  dataIndex: 'field51',   sorter: true},
        { title: '手机',  dataIndex: 'field52',   sorter: true},
        { title: '在职状态',  dataIndex: 'field53',   sorter: true,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }}
        ]
      },
    //详情
    dialogHandle(row,tpye){
      this.visible = true;
      const pram = {
        type: tpye,
        id:1001
      };
      this.initData=pram
    },
    //关闭详情
    dialogClose(data){
      this.visible=false
      // if (data.type === 'refresh') {
      //   // 重新加载
      //   this.fetchParams = { ...this.fetchParams };
      // }
    },
     collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    }
  }
};
</script>

<style lang="less" scoped>
</style>
